/*
 * 
 * LegendShop 多用户商城系统
 * 
 *  版权所有,并保留所有权利。
 * 
 */
package com.legendshop.security.handler;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.legendshop.oa.constants.LoginTypeEnum;
import com.legendshop.oa.constants.LoginUserTypeEnum;
import com.legendshop.oa.model.UserEntity;
import com.legendshop.oa.security.UserDetail;

public class UserDetailsServiceImpl implements UserDetailsService {
	

	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

		return null;
	}
	
    /**
     * 根据商家和用户转化为用户对象
     */
	private User createUser(UserEntity user,LoginUserTypeEnum loginUserType, LoginTypeEnum loginType, String opendId, String accessToken, String type) {
		User minuser = new UserDetail(user.getId(), user.getName(), user.getPassword(), user.getPortraitPic(), 
				getBoolean(user.getEnabled()), true, true, true, user.getRoles(), user.getFunctions(),
				user.getDeptId(),user.getRealName(),user.getPassChangeDate(), user.getChangePass());
		return minuser;
	}
	
	
	/**
	 * Gets the boolean.
	 * 
	 * @param b
	 *            the b
	 * @return the boolean
	 */
	private boolean getBoolean(String b) {
		return "1".endsWith(b) ? true : false;
	}

	

}
